package com.ruoyi.zsyh.controller;

import java.util.List;
import org.apache.shiro.authz.annotation.RequiresPermissions;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.ui.ModelMap;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;
import com.ruoyi.common.annotation.Log;
import com.ruoyi.common.enums.BusinessType;
import com.ruoyi.zsyh.domain.ZsyhPlatformPartsCheck;
import com.ruoyi.zsyh.service.IZsyhPlatformPartsCheckService;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.common.core.page.TableDataInfo;

/**
 * 配件鉴定权Controller
 * 
 * @author yuexl
 * @date 2022-02-09
 */
@Controller
@RequestMapping("/zsyh/partsCheck")
public class ZsyhPlatformPartsCheckController extends BaseController
{
    private String prefix = "zsyh/partsCheck";

    @Autowired
    private IZsyhPlatformPartsCheckService zsyhPlatformPartsCheckService;

    @RequiresPermissions("zsyh:partsCheck:view")
    @GetMapping()
    public String partsCheck()
    {
        return prefix + "/partsCheck";
    }

    @RequiresPermissions("zsyh:partsCheck:view")
    @GetMapping("/viewPartsCheck")
    public String viewPartsCheck(String storeId, ModelMap mmap)
    {
        mmap.put("storeId",storeId);
        return prefix + "/viewPartsCheck";
    }

    /**
     * 查询配件鉴定权列表
     */
    @RequiresPermissions("zsyh:partsCheck:list")
    @PostMapping("/list")
    @ResponseBody
    public TableDataInfo list(ZsyhPlatformPartsCheck zsyhPlatformPartsCheck)
    {
        startPage();
        List<ZsyhPlatformPartsCheck> list = zsyhPlatformPartsCheckService.selectZsyhPlatformPartsCheckList(zsyhPlatformPartsCheck);
        return getDataTable(list);
    }

    /**
     * 导出配件鉴定权列表
     */
    @RequiresPermissions("zsyh:partsCheck:export")
    @Log(title = "配件鉴定权", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    @ResponseBody
    public AjaxResult export(ZsyhPlatformPartsCheck zsyhPlatformPartsCheck)
    {
        List<ZsyhPlatformPartsCheck> list = zsyhPlatformPartsCheckService.selectZsyhPlatformPartsCheckList(zsyhPlatformPartsCheck);
        ExcelUtil<ZsyhPlatformPartsCheck> util = new ExcelUtil<ZsyhPlatformPartsCheck>(ZsyhPlatformPartsCheck.class);
        return util.exportExcel(list, "配件鉴定权数据");
    }

    /**
     * 新增配件鉴定权
     */
    @GetMapping("/add")
    public String add()
    {
        return prefix + "/add";
    }

    /**
     * 新增保存配件鉴定权
     */
    @RequiresPermissions("zsyh:partsCheck:add")
    @Log(title = "配件鉴定权", businessType = BusinessType.INSERT)
    @PostMapping("/add")
    @ResponseBody
    public AjaxResult addSave(ZsyhPlatformPartsCheck zsyhPlatformPartsCheck)
    {
        return toAjax(zsyhPlatformPartsCheckService.insertZsyhPlatformPartsCheck(zsyhPlatformPartsCheck));
    }

    /**
     * 修改配件鉴定权
     */
    @GetMapping("/edit/{id}")
    public String edit(@PathVariable("id") Long id, ModelMap mmap)
    {
        ZsyhPlatformPartsCheck zsyhPlatformPartsCheck = zsyhPlatformPartsCheckService.selectZsyhPlatformPartsCheckById(id);
        mmap.put("zsyhPlatformPartsCheck", zsyhPlatformPartsCheck);
        return prefix + "/edit";
    }

    /**
     * 修改保存配件鉴定权
     */
    @RequiresPermissions("zsyh:partsCheck:edit")
    @Log(title = "配件鉴定权", businessType = BusinessType.UPDATE)
    @PostMapping("/edit")
    @ResponseBody
    public AjaxResult editSave(ZsyhPlatformPartsCheck zsyhPlatformPartsCheck)
    {
        return toAjax(zsyhPlatformPartsCheckService.updateZsyhPlatformPartsCheck(zsyhPlatformPartsCheck));
    }

    /**
     * 删除配件鉴定权
     */
    @RequiresPermissions("zsyh:partsCheck:remove")
    @Log(title = "配件鉴定权", businessType = BusinessType.DELETE)
    @PostMapping( "/remove")
    @ResponseBody
    public AjaxResult remove(String ids)
    {
        return toAjax(zsyhPlatformPartsCheckService.deleteZsyhPlatformPartsCheckByIds(ids));
    }
}
